<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@page import="avicit.platform6.core.locale.PlatformLocalesJSTL"%>
<%@page import="java.util.Locale"%>
<%@page import="avicit.platform6.api.session.SessionHelper"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="avicit.platform6.commons.utils.ViewUtil"%>
<%@ taglib prefix="sec" uri="/WEB-INF/tags/shiro.tld"%>
<%@page import="avicit.platform6.api.sysshirolog.impl.AfterLoginSessionProcess"%>
<% 
Object lang=session.getAttribute(AfterLoginSessionProcess.SESSION_CURRENT_LANGUAGE_CODE);
String languageCode="zh_CN";
if(lang!=null){
	languageCode=lang.toString();
}
	Locale locale =SessionHelper.getLocaleByUser(request);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>结构定义</title>
<base href="<%=ViewUtil.getRequestPath(request)%>">
<link href="static/css/custom/lantop/css/custom.css" type="text/css"  rel="stylesheet">
<jsp:include
	page="/avicit/platform6/component/common/EasyUIJsInclude.jsp"></jsp:include>
<script type="text/javascript"
	src="avicit/cbb/techclass/tabledefine/commtablemanager/table_structure.js"></script>
<jsp:include page="/avicit/im/common/ImUIJSCSSInclude.jsp"></jsp:include>
<script type="text/javascript"
	src="avicit/cbb/techclass/tabledefine/commtablemanager/locale/language_<%=languageCode%>.js"></script>
<%
	String sysId = request.getParameter("sysId");
	String tableName = request.getParameter("tableName");
	String nodeTypeNew = request.getParameter("nodeType");
	String nodeId = request.getParameter("nodeId");
	String nodeName = request.getParameter("nodeName");
	String nodeCode = request.getParameter("nodeCode");
	String copyNodeData = request.getParameter("copyNodeData");//复制页面的第二颗树 数据源 视图
%>
<script type="text/javascript">
var baseurl = "<%=ViewUtil.getRequestPath(request)%>";
	//此事件必须放在jsp中,不能提取到js中,否则不能加载数据
	$(function() {
		sysId = "<%=sysId%>";
		tableName = "<%=tableName%>";
		nodeTypeNew = "<%=nodeTypeNew%>";
		nodeId = "<%=nodeId%>";
		nodeName = "<%=nodeName%>";
		nodeCode = "<%=nodeCode%>";
		copyNodeData = "<%=copyNodeData%>";
		if ("" == tableName || "null" == tableName) {
			tableName = "CBB_CS_WJ";
		}
		if ("" == nodeTypeNew || "null" == nodeTypeNew) {
			nodeTypeNew = "Y";
		}
		if (nodeTypeNew == "N") {
			$('#addTempField').linkbutton('disable');
			$('#deleteTempField').linkbutton('disable');
			$('#saveTempField').linkbutton('disable');
			$('#openTemplet').linkbutton('disable');
		}
		if ("" == sysId || "null" == sysId) {
			sysId = "CBB";
		}
		if ("" == nodeId || "null" == nodeId) {
			nodeId = "-1";
		}
		if ("" == nodeName || "null" == nodeName) {
			nodeName = "测试";
		}
		document.getElementById("selectCol").style.display = 'none';
		$('#cbbTabColumnsDataGrid').datagrid({
			url : 'platform/aos/commtablemanagerController/getCbbTabColumnsData.json?sysId=' + sysId + '&tableName=' + tableName + '&isTemplet=' + isTemplet
		});
		$.ajax({
			url : 'platform/aos/commtablemanagerController/checkColIsMust',
			data : {
				sysId : sysId,
				tableName : tableName
			},
			type : 'post',
			dataType : 'json',
			success : function(result) {
				isTrueTable = result.isTrueTable;//是否为真实表；Y：真是表，N：虚拟表
				if (result.flag == "failure") {
					isHasData = true;
				} else {
					isHasData = false;
				}
				//虚拟表隐藏部分按钮
				if (isTrueTable == "N") {
					$('#createMenu').linkbutton('disable');
				}
			}
		});
		//给隐藏表格加载数据
		$('#hiddenTable').datagrid({
			url : 'platform/aos/commtablemanagerController/getHiddenCbbTabColumnsData.json?sysId=' + sysId + '&tableName=' + tableName + '&isTemplet=' + isTemplet
		});
		if(parent.parent.currentOrgId!='ORG_ROOT'){
			$('#addTempField').linkbutton('disable');
			$('#deleteTempField').linkbutton('disable');
			$('#syncToSubOrg').linkbutton('disable');
		}

	});
	// SanXiaFiles Create By Tangkun start
	function getResultByInput(){
		$('#cbbTabColumnsDataGrid').datagrid({
			url : 'platform/aos/commtablemanagerController/getCbbTabColumnsData.json?sysId=' + sysId + '&tableName=' + tableName + '&isTemplet=' + isTemplet
					+ '&colName=colName&colLabel=colLabel&colType=colType&inputWord=' + encodeURI(encodeURI($('#query').val()))
		});
	}
	function keyDownQuery(){
		if(event.keyCode==13){
			getResultByInput();
		}
	}
	// SanXiaFiles Create By Tangkun End
//SanXiaFiles Create By huangjian start 表格序号自增
	function formatFnNum(val,row,index){
		return (index + 1);
	}
//SanXiaFiles Create By huangjian End 表格序号自增
</script>
<style type="text/css">
.textbox {
	border: solid 1px #a5acb5;
}

.input,img {
	vertical-align: middle;
}

<!--
实现input和img水平对齐 -->.labelbg {
	background:
		url('../../js/jQuery/jquery-easyui-1.3.5/themes/icons/required.gif')
		right 0 no-repeat;
}
.selbtnc{
	margin-left:5px;
}
.icon-im-newndisallfield{
   margin-top:0px !important;
}
</style>
</head>
<body id="myBody" class="easyui-layout" data-options="fit:true">
	<div id="tb" style="overflow: hidden; font-size: 0;padding:10px 0px;margin-top:0px;margin-left:-0.9%;">
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_addField">
			<%-- 添加字段 --%>
			<a class="easyui-linkbutton selbtnc" style="margin-left: 28px;" iconCls="icon-im-add" onclick="append();" href="javascript:void(0);" id="addTempField"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.addField","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_deleteField">
			<%-- 删除字段 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-remove" onclick="removeit();" href="javascript:void(0);" id="deleteTempField"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.deleteField","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_saveField">
			<!-- 保存 -->
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-save" onclick="accept();" href="javascript:void(0);" id="saveTempField"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.save","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_selectAllCol">
			<%-- 显示全部字段 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-newndisallfield" onclick="selectAllCol();" href="javascript:void(0);" id="selectAllCol"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.showAllField","i18n.lantop",locale)%></a>
			<%-- 显示基本字段 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-newnhideallfield" onclick="selectAllCol();" href="javascript:void(0);" id="selectCol"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.showAllField.showBasicField","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_export">
			<%-- 导出结构数据 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-export" onclick="exportData();" href="javascript:void(0);" id="export"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.exportStructureData","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_importExcel">
			<%-- 导入结构数据 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-im-import" onclick="openImportDialog();" href="javascript:void(0);" id="importExcel"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.importStructureData","i18n.lantop",locale)%></a>
		</sec:accesscontrollist>
		<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_button_syncToSubOrg">
			<%-- 同步至下级组织 --%>
			<a class="easyui-linkbutton selbtnc" iconCls="icon-setting" onclick="syncToSubOrg();" href="javascript:void(0);" id="syncToSubOrg">同步至下级组织<%--<%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.button.syncToSubOrg","i18n.lantop",locale)%>--%></a>
		</sec:accesscontrollist>
		<div style="background: white; width: 150px; height: 25px; margin-right: 10px; border-radius: 3px; border: 1px solid #ccc; float: right;">
			<input placeholder="快速检索" type="text" id="query" onblur="getResultByInput()" onkeydown="keyDownQuery()"
				style="float: left; box-sizing: border-box; padding-left: 5px; width: 123px; height: 25px; outline: none; border: none;" />
			<img src="avicit/im/lantop/common/search/image/icon_tool14.png"
				style="float: right; margin-top: 2px; margin-right: 2px;cursor: pointer;">
		</div>
		<!-- 
		 SanXiaFiles Create By Tangkun End  
		-->
	</div>
	<div data-options="region:'center',border:false,fit:true" id="colTab" style="height: 0; overflow: hidden; font-size: 0;">
		<table id="cbbTabColumnsDataGrid" data-options="
			rownumbers: false,
			animate: true,
			collapsible: false,
			fitColumns: true,
			autoRowHeight: false,
			singleSelect: true,
			pagination:true,
			pageSize:10, 
			pageList:[100,150,200], 
    		striped:true,
			fit:true,
			scrollbarSize:0,
			method: 'post',
			onClickCell:onClickCell,
			selectOnCheck:false,
			checkOnSelect:false,
			toolbar: '#tb'
		">
			<thead>
				<tr>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_id">
						<th data-options="field:'id', halign:'center',checkbox:true" title="主键ID" width="20">主键ID</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_fn">
						<th data-options="field:'fnNum', halign:'center',align:'center'" formatter="formatFnNum" title="序号" width="40">序号</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colLabel">
						<%-- 字段中文名 --%>
						<th data-options="field:'colLabel',halign:'center', align:'center', editor:{type:'validatebox',options:{required:true,validType:'length[0,20]'}},formatter:fomaterColLabel" width="110" title="字段中文名"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填"> <%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.fieldCHNName","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colName">
						<%-- 字段名 --%>
						<th data-options="field:'colName', halign:'center', align:'center', editor:{type:'validatebox',options:{required:true,validType:'length[0,30]'}},formatter:fomaterColName" width="100" title="字段名"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.fieldName","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colType">
						<%-- 字段类型 --%>
						<th data-options="field:'colType', halign:'center', align:'center',editor:{type:'combobox',options:{onSelect : typeSelect,onHidePanel: typeOnHidePanel,required:true,panelHeight: 'auto',valueField:'lookupCode',textField:'lookupName',data:[{lookupCode:'string',lookupName:'字符串'},{lookupCode:'integer',lookupName:'整型'},{lookupCode:'date',lookupName:'日期时间型'},{lookupCode:'float',lookupName:'浮点型'},{lookupCode:'blob',lookupName:'BLOB'},{lookupCode:'clob',lookupName:'CLOB'}],editable:false}},formatter:fomaterColType" width="100" title="字段类型"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.fieldType","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colLength">
						<%-- 长度 --%>
						<th data-options="field:'colLength', halign:'center', align:'center', editor:{type:'numberbox',options:{'validType':'length[0,5]'}},formatter:fomaterColLength" width="100" title="长度"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.length","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colDecimal">
						<%-- 小数位数 --%>
						<th data-options="field:'colDecimal', halign:'center', align:'center', editor:{type:'numberbox',options:{'validType':'length[1,6]'}},formatter:fomaterColDecimal" width="100" title="小数位数"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.decimalNum","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colIsSys">
						<%-- 系统字段 --%>
						<th data-options="field:'colIsSys', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsSys" width="100" title="系统字段"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.systemField","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_ttribute04">
						<%-- 是否可见 --%>
						<th data-options="field:'colIsDisplay', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsShow" width="100" title="是否可见"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.isVisible","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colIsMust">
						<%-- 是否必著 --%>
						<th data-options="field:'colIsMust', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsMust" width="100" title="是否必著"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.isMustRecord","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colOrder">
						<%-- 表单顺序 --%>
						<th data-options="field:'colOrder', halign:'center', align:'center',editor:{type:'numberbox',options:{'validType':'length[0,4]'}},formatter:fomaterColOrder" width="40" title="顺序">表单顺序</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_attribute11">
						<%-- 表格顺序 --%>
						<th data-options="field:'attribute11', halign:'center', align:'center',editor:{type:'numberbox',options:{'validType':'length[0,4]'}},formatter:fomaterColTabOrder" width="40" title="顺序">表格顺序</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_remark">
						<%-- 备注 --%>
						<th data-options="field:'remark', halign:'center', align:'center', editor:{type:'validatebox',options:{'validType':'length[0,200]'}},formatter:fomaterRemark" width="100" title="备注"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.libstructuredefine.structureDefine.table.comment","i18n.lantop",locale)%></th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_isNew">
						<th data-options="field:'isNew', halign:'center', align:'center',hidden: true,editor:{type:'text'}" width="100" title="是否新建">是否新建</th>
					</sec:accesscontrollist>
				</tr>
			</thead>
		</table>
	</div>
	<!-- 放一个隐藏table用于页面对于字段名的重复验证 -->
	<div data-options="region:'south', border:false,fit:true" id="colTab2" style="height: 0; font-size: 0; display: none">
		<table id="hiddenTable" data-options="
			rownumbers: true,
			animate: true,
			collapsible: false,
			fitColumns: true,
			autoRowHeight: false,
			singleSelect: true,
			pagination:true,
			pageSize:10, 
			pageList:[100,150,200], 
    		striped:true,
			fit:true,
			method: 'post',
			selectOnCheck:false,
			checkOnSelect:false
		">
			<thead>
				<tr>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_id">
						<th data-options="field:'id', halign:'center',checkbox:true" title="主键ID" width="20">主键ID</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colLabel">
						<th data-options="field:'colLabel',halign:'center', align:'center', editor:{type:'validatebox',options:{required:true,validType:'length[0,20]'}},formatter:fomaterColLabel" width="100" title="字段中文名"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填"> 字段中文名</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colName">
						<th data-options="field:'colName', halign:'center', align:'center', editor:{type:'validatebox',options:{required:true,validType:'length[0,30]'}},formatter:fomaterColName" width="100" title="字段名"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填">字段名</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colType">
						<th data-options="field:'colType', halign:'center', align:'center',editor:{type:'combobox',options:{onSelect : typeSelect,onHidePanel: typeOnHidePanel,required:true,panelHeight: 'auto',valueField:'lookupCode',textField:'lookupName',data:[{lookupCode:'string',lookupName:'字符串'},{lookupCode:'integer',lookupName:'整型'},{lookupCode:'date',lookupName:'日期时间型'},{lookupCode:'float',lookupName:'浮点型'},{lookupCode:'blob',lookupName:'BLOB'},{lookupCode:'clob',lookupName:'CLOB'}],editable:false}},formatter:fomaterColType" width="100" title="字段类型"><img src="avicit/im/common/im_themes_extend/required.gif" alt="必填">字段类型</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colLength">
						<th data-options="field:'colLength', halign:'center', align:'center', editor:{type:'numberbox',options:{'validType':'length[0,5]'}},formatter:fomaterColLength" width="100" title="长度">长度</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colDecimal">
						<th data-options="field:'colDecimal', halign:'center', align:'center', editor:{type:'numberbox',options:{'validType':'length[1,6]'}},formatter:fomaterColDecimal" width="100" title="小数位数">小数位数</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colIsSys">
						<th data-options="field:'colIsSys', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsSys" width="100" title="系统字段">系统字段</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_ttribute04">
						<th data-options="field:'colIsDisplay', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsShow" width="100" title="是否可见">是否可见</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colIsMust">
						<th data-options="field:'colIsMust', halign:'center', align:'center',editor:{type:'text'},formatter:fomaterIsMust" width="100" title="是否必著">是否必著</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_colOrder">
						<th data-options="field:'colOrder', halign:'center', align:'center',editor:{type:'numberbox',options:{'validType':'length[0,4]'}},formatter:fomaterColOrder" width="100" title="顺序">表单顺序</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_attribute11">
						<th data-options="field:'attribute11', halign:'center', align:'center',editor:{type:'numberbox',options:{'validType':'length[0,4]'}},formatter:fomaterColTabOrder" width="100" title="顺序">表格顺序</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_remark">
						<th data-options="field:'remark', halign:'center', align:'center', editor:{type:'validatebox',options:{'validType':'length[0,200]'}},formatter:fomaterRemark" width="100" title="备注">备注</th>
					</sec:accesscontrollist>
					<sec:accesscontrollist hasPermission="3" domainObject="commtablemanager_table_structure_datagrid_isNew">
						<th data-options="field:'isNew', halign:'center', align:'center',hidden: true,editor:{type:'text'}" width="100" title="是否新建">是否新建</th>
					</sec:accesscontrollist>
				</tr>
			</thead>
		</table>
	</div>
</body>
<script type="text/javascript" src="static/js/platform/index/js/divscroll.js" ></script>
<script>
	$(function(){
		$(".datagrid-view2").find(".datagrid-body").perfectScrollbar();
	});
</script>
</html>



